package org.example.utils;

import org.example.common.GlobalConts;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 李国树
 * @version 1.0
 * @Desc 获取当前登录的用户id
 * @date 2023/11/11 11:14
 */
public class LoginUtils {
    public static Integer getLoginSuccessUserId(HttpServletRequest request) {
        String loginUserIdStr = request.getHeader(GlobalConts.LOGIN_SUCCESS_USER_HEADER_KEY);
        try {
            int loginUserId = Integer.parseInt(loginUserIdStr);
            return loginUserId;
        } catch (Exception e) {
            return null;
        }
    }
}

 
